﻿using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace Mrhd.Core.Entities
{
    /// <summary>
    /// 移动端用户表
    /// </summary>
    [Table("Sys_UserMobile")]
    [Comment("移动端用户表")]
    public class UserMobileEntity: Entity, IEntitySeedData<UserMobileEntity>
    {
        /// <summary>
        /// 小程序的唯一标识
        /// </summary>
        [Comment("小程序的唯一标识")]
        [MaxLength(64)]
        public string OpenId { get; set; }
        /// <summary>
        /// 昵称
        /// </summary>
        [Comment("昵称")]
        [MaxLength(32)]
        public string NickName { get; set; }
        /// <summary>
        /// 头像地址
        /// </summary>
        [Comment("头像地址")]
        [MaxLength(512)]
        public string FaceUrl { get; set; }
        /// <summary>
        /// 国家
        /// </summary>
        [Comment("国家")]
        [MaxLength(16)]
        public string Country { get; set; }
        /// <summary>
        /// 省份
        /// </summary>
        [Comment("省份")]
        [MaxLength(16)]
        public string Province { get; set; }
        /// <summary>
        /// 城市
        /// </summary>
        [Comment("城市")]
        [MaxLength(16)]
        public string City { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        [Comment("性别")]
        public GenderType Gender { get; set; }
        /// <summary>
        /// 手机号
        /// </summary>
        [Comment("手机号")]
        [MaxLength(32)]
        public string Phone { get; set; }
        /// <summary>
        /// 是否已经注册
        /// </summary>
        [Comment("是否已经注册")]
        public bool IsRegister { get; set; }
        /// <summary>
        /// 默认商户
        /// </summary>
        [Comment("默认商户")]
        public int? DefualtBusiness { get; set; }
        /// <summary>
        /// 绑定关系
        /// </summary>
        public virtual ICollection<UserMobileToBusinessEntity> Businesses { get; set; }

        public IEnumerable<UserMobileEntity> HasData(DbContext dbContext, Type dbContextLocator)
        {
            var time = new DateTimeOffset(2021, 9, 21, 8, 0, 0, default);
            return new List<UserMobileEntity>
            {
                new UserMobileEntity{ Id = 1, OpenId = "123456abc", NickName = "华天晓", City = "武汉", Country = "中国", CreatedTime = time, Gender = GenderType.Male, IsRegister = true, Phone = "17354300837", Province = "湖北" },
                new UserMobileEntity{ Id = 2, OpenId = "L41522365", NickName = "芥", City = "襄阳", Country = "中国", CreatedTime = time.AddMinutes(2), Gender = GenderType.Female, IsRegister = true, Phone = "18956632214", Province = "湖北" }
            };
        }
    }
}
